<?php


class TagLibBlog extends TagLib {
	protected $tags = array(
			'new_post' => array('attr'=>'limit','close'=>0),
			'hot_post' => array('attr'=>'limit','close'=>0),
		);

	public function _new_post($attr, $content){
		$tag    = $this->parseXmlAttr($attr,'new_post');
        $limit   =   $tag['limit'];
		$str = <<<STR
<?php

\$_new_list = M('Post')->order('add_time desc')->limit($limit)->field('id,title')->select();
foreach(\$_new_list as \$v){
	\$str = '<li>';
	\$str .= "<a href=" . U("/\$v[id]") .">";
	\$str .= \$v['title'];
	\$str .= '</a></li>';
	echo \$str;
}

?>
STR;
		return $str;
	}

	public function _hot_post(){
		$tag    = $this->parseXmlAttr($attr,'hot_post');
		$limit   =   $tag['limit'];
		$str = <<<STR
<?php

\$_hot_list = M('Post')->order('click desc')->limit($limit)->field('id,title')->select();
foreach(\$_hot_list as \$v){
\$str = '<li>';
\$str .= "<a href=" . U("/\$v[id]") .">";
\$str .= \$v['title'];
\$str .= '</a></li>';
echo \$str;
}

?>
STR;
		return $str;

	}

}